export default {
	methods: {
		async GetMaintainPartList() {
			console.log("关键字",this.prodKeyword);
			let result = await this.workordercompleteservice.GetMaintainPartListByPartNum(this.UserInfo.mobile,
				this.prodKeyword, this.woId,this.UserInfo.RetId);
			if (result && result.RetBool) {	
				return result.RetObject;
			} else {
				console.log(result.RetMsg);
				throw result.RetMsg;
			}
		},
		async GetProdImages(imageIds) {
			if (imageIds.length > 0) {
				let uPhone = this.UserInfo.mobile;
				let token = this.UserInfo.RetId;
				let result = await this.commService.ImageReaderAsync(uPhone, imageIds, 1, token);
				if (result.RetBool && result.RetObject) {
					return JSON.parse(result.RetObject)
				}
				return null;
			}
			return
		},
		
		async setProdPageImg(productPage) {
			//let productPage = this.MaintainPartList;
			let imageArray = new Array();
			for (let index in productPage) {
				if (productPage[index].ImgId)
					imageArray.push(productPage[index].ImgId)
			}
			let imageids = imageArray.join(",");
			let imgresult = await this.GetProdImages(imageids);
		
			for (let imgindex in imgresult) {
				let prodIndex = productPage.findIndex(prodItem => {
					return imgresult[imgindex].ImgId === prodItem.ImgId
				});
				if (prodIndex > -1)
					productPage[prodIndex].base64Img = `data:image/jpeg;base64,${imgresult[imgindex].ImgBaseStr}`;
			}
			//return productPage;
			console.log(productPage)
		},
		
	}
}
